package com.frejoys.service;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.frejoys.common.dto.admin.StoreResourceLibraryListDto;
import com.frejoys.common.dto.common.IdDto;
import com.frejoys.common.dto.common.resourcelibrary.ResourceLibraryListDto;
import com.frejoys.common.vo.admin.AdminResourceLibraryListVo;
import com.frejoys.common.vo.common.ResourceLibraryVo;
import com.frejoys.common.vo.store.ResourceLibraryListVo;
import com.frejoys.dao.entity.ResourceLibrary;

import java.util.List;

public interface ResourceLibraryService extends IService<ResourceLibrary> {

    default ResourceLibrary getOnly(QueryWrapper<ResourceLibrary> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    default ResourceLibrary getOnly(LambdaQueryWrapper<ResourceLibrary> wrapper) {
        wrapper.last("limit 1");
        return this.getOne(wrapper);
    }

    // 添加信息
    boolean addInfo(Long userId, String name, Integer site);

    boolean upStatus(Long userId, String name, Integer status);

    boolean upStatus(String name, Integer status);

    boolean upStatus(String name, Integer oldStatus, Integer newStatus);

    boolean upStatus(Integer id, Integer status);

    // 删除信息
    boolean delInfo(IdDto dto);

    // 删除信息
    boolean delInfo(String name);

    // 批量删除
    boolean delInfo(List<String> name);

    // 获取信息
    ResourceLibraryVo getInfo(IdDto dto);

    // 获取信息
    ResourceLibraryVo getInfo(Long userId, String name);

    // 获取列表
    List<ResourceLibraryVo> listInfo(Long userId, ResourceLibraryListDto dto);


    /** 查询资源库列表
     *
     * @param dto
     * @return
     */
    List<ResourceLibraryListVo> resourceLibraryListInfo(StoreResourceLibraryListDto dto);

    /**
     *  管理员查看资源库列表
     * @param dto
     * @return
     */
    IPage<AdminResourceLibraryListVo> adminResourceLibraryListInfo(StoreResourceLibraryListDto dto);
}
